package net.mukia.repository.impl.hibernate;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import net.mukia.repository.ArticleRepository;
import net.mukia.model.Article;

@Repository("articleRepository")
public class HibernateArticleRepository extends BaseRepository<Article> implements ArticleRepository {

	@SuppressWarnings("unchecked")
	public List<Article> selectAll(Article article) {
		Criteria creiteria = getSession().createCriteria(Article.class);
		if (null != article && null != article.getTitle()) {
			creiteria = creiteria.add(Restrictions.like("title", article.getTitle()));
		}
		return ((List<Article>) creiteria.list());
	}

}
